﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Runtime.InteropServices;

namespace OSVDB_TrayApp
{
    class WindowHelper
    {
        [DllImport("user32.dll")]
        private static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);

        [DllImport("user32.dll")]
        private static extern bool GetWindowRect(IntPtr hWnd, out Rectangle lpRect);

        public static int GetTaskbarHeight()
        {
            IntPtr handleTaskbar = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Shell_TrayWnd", "");
            if (handleTaskbar == IntPtr.Zero) return (0);

            Rectangle taskbarRect;
            GetWindowRect(handleTaskbar, out taskbarRect);

            return (taskbarRect.Height - taskbarRect.Y);
        }
    }
}
